requirements. For example, you can specify which version of Python and which libraries/modules you want

installed in a particular virtual environment.

As an example, to create a virtual environment in the PythonAnywhere bash, we run:

Analyze Command

mkvirtualenv -p python3.8 <environment name>

In the above, we have specified that we use Python 3.8 in the virtualenv. Whatever packages we install will always

be there and independent of other virtualenvs.

If I ran:

Execute in Terminal

mkvirtualenv -p python3.8 todoappenv

I will see the name of the virtualenv in the Bash which means we are in the VE eg:

(todoappenv) 00:08 ~ $

Back in our virtualenv, we need to install django, djangorestframework, django-cors-headers (as what we have done

in development). So run:

Execute in Terminal

pip install django djangorestframework django-cors-headers

Setting up your Web app

At this point, you need to be ready with 3 pieces of information:

1. The path to your Django project's top folder -- the folder that contains "manage.py". A simple way to get this is,

in your project folder in bash, type pwd. Eg: /home/greglim/todoapp

2. The name of your project (the name of the folder that contains your settings.py), e.g. backend

3. The name of your virtualenv, eg todoappenv

Create a Web app with Manual Config

In your browser, open a new tab and go to the PythonAnywhere dashboard. Click on the ‘ Web ’ tab (fig. 29.4).

Figure 29.4

Click, ‘ Add a new web app ’ . Under ‘ Select a Python Web framework ’ , choose the ‘ Manual Configuration ’

(fig. 29.5).

Figure 29.5

NOTE: Make sure you choose ‘Manual Configuration’, not the ‘Django’ option, that's for new projects only.

Select the right version of Python (the same one you used to create your virtualenv).

Enter your virtualenv name

Enter the name of your virtualenv in the Virtualenv section (fig. 29.6).